<template>
    <div class="toreceived">
        <div class="head">
            <div class="head_left"><van-icon name="arrow-left" @click="back" /></div>
            <div class="head_mid">
                <div class="head-box">已收货</div>
            </div>
            <div class="head_right"></div>
        </div>
        <div class="product">
            <div class="product_item" v-for="(i, ind) in productlist.res" :key="ind">
                <div class="product_img">
                    <img :src="i.product_img" alt="" />
                </div>
                <div class="product_content">
                    <p>{{ i.product_name }}</p>
                </div>
                <div class="product_price_count">
                    <div class="pc_box">
                        <div class="product_price">
                            <span class="icon">¥</span><span class="price">{{ i.product_price }}</span>
                        </div>
                        <div class="product_count">共{{ i.product_num }}件</div>
                    </div>

                    <div class="but">已收货</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import { getToReceived } from "../../request/index.js";
let router = useRouter();
let userid = ref("");
let productlist = reactive({ res: [] });
userid.value = localStorage.getItem("user_id");
getToReceived({ user_id: userid.value }).then((res) => {
    console.log(res);
    let { code, data } = res;
    if (code == 200) {
        productlist.res = data;
    }
});
let back = () => {
    router.go(-1);
};
</script>

<style lang="scss" scoped>
.toreceived {
    .head {
        color: #666666;
        box-shadow: 0 0 5px 1px #e5e5e5;
        height: 2.8125rem;
        display: flex;
        .head_left {
            font-size: 1.25rem;
            width: 3.25rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .head_mid {
            font-size: 1.0625rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex: 1;
        }
        .head_right {
            width: 3.25rem;
        }
    }
    .product {
        margin-top: 0.9375rem;
        padding: 0 0.625rem;
    }
    .product_item {
        background-color: #fff;
        padding: 10px 2px;
        border-radius: 6px;
        display: flex;
        margin-bottom: 0.625rem;
        .product_img {
            width: 6.25rem;
            height: 6.25rem;
            border-radius: 6px;
            overflow: hidden;
            img {
                width: 100%;
                height: 100%;
            }
        }
        .product_content {
            display: flex;
            align-items: center;
            padding: 0 0.3125rem;
            word-break: break-all;
            flex: 1;
            line-height: 18px;
            p {
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 3;
                font-size: 15px;
            }
        }
        .product_price_count {
            width: 5.625rem;
            height: 6.25rem;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            align-items: center;
            .pc_box {
                display: flex;
                align-items: center;
                flex-direction: column;
                justify-content: center;
                height: 70px;
            }
            .product_price {
                .icon {
                    font-size: 12px;
                }
                .price {
                    font-size: 22px;
                }
            }
            .product_count {
                font-size: 14px;
            }
            .but {
                box-sizing: border-box;
                border: 1px solid #ff5254;
                font-size: 14px;
                padding: 6px 10px;
                border-radius: 2rem;
                margin-top: 10px;
                color: #ff5757;
            }
        }
    }
}
</style>
